//
//  BSKCurrentTheme.m
//  MicroMemory
//
//  Created by rimi on 16/7/24.
//  Copyright © 2016年 BlueSky. All rights reserved.
//

#import "BSKCurrentTheme.h"

@implementation BSKCurrentTheme
- (instancetype)initWithThemeImage:(UIImage *)image
{
    self = [super init];
    if (self) {
        self.themeImage = image;
    }
    return self;
}

+(BSKCurrentTheme *)curentTheme{
    static BSKCurrentTheme * shareTheme = nil;
    if (!shareTheme){
        shareTheme = [[BSKCurrentTheme alloc] initWithThemeImage:[UIImage imageNamed:@"paper1"]];
    }
    return shareTheme;
}

-(void)setThemeColor:(UIColor *)themeColor{
    CGFloat red = 0;
    CGFloat green = 0;
    CGFloat blue = 0;
    CGFloat alpha = 0;
    
    _themeColor = themeColor;
    [_themeColor getRed:&red green:&green blue:&blue alpha:&alpha];
    _noteBackgroundColor = [UIColor colorWithRed:red green:green blue:blue alpha:0.3];
    red+=0.2;
    green += 0.2;
    blue +=0.2;
    if (red>1) {
        red = 1;
    }
    if (blue > 1) {
        blue = 1;
    }
    if (green > 1) {
        green = 1;
    }
    _menuThemeColors = @[(id)_themeColor.CGColor,(id)[UIColor colorWithRed:red green:green blue:blue alpha:alpha].CGColor,(id)_themeColor.CGColor];
}

-(void)setThemeImage:(UIImage *)themeImage {
    if (themeImage) {
        self.themeColor = [themeImage MainColorOfImage];
        _themeImage = themeImage;
    }
}
@end
